package oop8;

import oop6.pet2.Dog;
import oop6.pet2.Penguin;
import oop6.pet2.Pet;

/**
 * @author oldliu
 * @since 1.0
 */
public class PetTest10 {
    public static void main(String[] args) {
        //强转不成功的情况：
        Pet d = new Penguin("小蓝企鹅");
        //Pet d = new Dog("大黄", 3, "公", 100, 100, "田园犬");
        d.print();
        if (d instanceof Penguin) {
            Penguin penguin = (Penguin) d;
            penguin.swim();
        }else{
            System.out.println("这不是企鹅，不会游泳！");
        }
        //错误
//        Penguin penguin=(Penguin)d;
//        penguin.swim();
    }
}
